package web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import beans.PersonInformation;
import beans.TypeMessage;
import beans.Typer;
import service.TypeMessageService;
import service.TypeService;
import serviceimpl.SearchByUsernameServiceIpmt;
import serviceimpl.TypeMessageServiceIpml;
import serviceimpl.TypeServiceIpmt;
@WebServlet("/SearchByUsernameServalet")
public class SearchByUsernameServalet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		SearchByUsernameServiceIpmt ipmt = new SearchByUsernameServiceIpmt();
		String username=request.getParameter("name");
		
		List<PersonInformation> list = ipmt.searchByUsernameService(username);
		String json = String.valueOf(JSON.toJSON(list));
		response.setContentType("text/plain;charset=utf-8");
		response.getWriter().write(json);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
